package ltd.smallwang.infrastructure.task.db.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * @author justd
 */
@Data
@TableName("task")
public class TaskPo {
  @TableId(type = IdType.AUTO)
  private Long id;

  private String name;

  private String description;

  private Long userId;

  private String userName;

  private LocalDateTime deadline;

  private Integer completeFlag;

  private LocalDateTime completeTime;

  private Integer categoryId;

  @TableField(fill = FieldFill.INSERT)
  private LocalDateTime createTime;

  @TableField(fill = FieldFill.INSERT_UPDATE)
  private LocalDateTime modifyTime;

  @TableField(exist = false)
  private TaskCategoryPo taskCategoryPo;

  /**
   * 获取相反的完成状态
   *
   * @return the reverse complete flag
   */
  public Integer getReverseCompleteFlag() {
    if (completeFlag == 0) {
      return 1;
    }
    return 0;
  }

  /**
   * 检查任务是否完成。
   *
   * @return boolean - 如果任务完成，则返回true；否则返回false。
   */
  public boolean checkComplete() {
    return completeFlag == 1;
  }
}
